package com.AAA.service.Impl.scl;


import com.AAA.dao.scl.ITSclMapper;
import com.AAA.entity.MyPage;
import com.AAA.entity.scl.TScl;
import com.AAA.entity.sds.TSdsRecord;
import com.AAA.entity.sds.TSdsRecordjieguo;
import com.AAA.service.scl.ITsclService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TsclServiceimpl implements ITsclService {

    @Autowired
    private ITSclMapper mapper;

    @Override
    public PageInfo selectfy(MyPage myPage, TScl tScl) {
        PageHelper.startPage(myPage.getPage(), myPage.getLimit());
        List<TScl> select = mapper.selectfy(tScl);
        PageInfo pageInfo = new PageInfo<>(select);
        return pageInfo;
    }
    //批量添加
    @Override
    public Integer addall(TScl tScl) {
        int insert = mapper.insert(tScl);
        if(insert >0){
            return 1;
        }
        return 0;
    }
    @Override
    public boolean add(TScl tScl) {
        int insert = mapper.insert(tScl);
        if (insert>0){
            return true;
        }
        return false;
    }

    @Override
    public PageInfo getAll(MyPage myPage) {

        PageHelper.startPage(myPage.getPage(),myPage.getLimit());

        return new PageInfo(mapper.selectAll());
    }

    @Override
    public boolean edit(TScl tScl) {
        int insert=mapper.updateByPrimaryKeySelective(tScl);
        if(insert>0){
            return true;
        }else {
            return false;
        }

    }

    //删除
    @Override
    public boolean delete(Integer qid) {
        //deleteByPrimaryKey 获取实体类定义的id值  进行删除
        int insert = mapper.deleteByPrimaryKey(qid);
        if (insert>0){
            return true;
        }
        return false;
    }


    @Override
    public void save(List<TScl> list) {
        mapper.insertScljects(list);
    }

    @Override
    public TScl selectById(Integer qid) {
        return mapper.selectByPrimaryKey(qid);
    }

}
